# helpers
//= require jquery.min
//= require bootstrap-tab
//= require bootstrap-modal
//= require bootstrap-alert
//= require bootstrap-tooltip
//= require bootstrap-dropdown
//= require bootstrap-popover

window.$s = {}

$s.alert = (type, msg)->
  $('#alert').html(
    "
    <div class=\"alert alert-#{type}\">
      <button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>
      #{msg}
    </div>
    "
  )

$s.alert_hide = ->
  $('.alert').remove()

$(->

  $('.disabled').click ->
    false

  $('.sns-submit').click ->
    $.ajax
      url:  "/sns"
      type: "post"
      data:
        users:    $('#sns_txt').val()
        t: $(this).attr('data')
      success: (retval)->
        console.log retval
        msg = retval.msg || {}
        $s.alert(msg.type, msg.content)
)
